package com.ruoyi.server.api.wxlogin.controller;


import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.server.api.wxlogin.entiy.WxLoginVo;
import com.ruoyi.server.api.wxlogin.service.WxLoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;

/**
 * @Description TODO 小程序微信授权登录
 * @ClassName WxLoginController
 * @Date 2023/4/10 19:03
 **/
@RestController
@RequestMapping("/wxLogin")
public class WxLoginController extends BaseController {

    @Autowired
    WxLoginService wxLoginService;

    /**
     * @param code
     * @Description 获取openid
     * @Author HH
     * @Date 2023/4/11 11:04
     * @Return com.zhuiYun.project.common.response.AjaxResult
     */
    @PostMapping("/getOpenid")
    public AjaxResult getOpenid(@RequestBody String code) throws IOException {
        return success(wxLoginService.getOpenid(code));
    }


//    /**
//     * @param user
//     * @Description 小程序微信授权用户登录
//     * @Author HH
//     * @Date 2023/4/10 18:55
//     * @Return com.zhuiYun.project.common.response.AjaxResult
//     */
//    @PostMapping("/login1")
//    public AjaxResult login(@RequestBody AppUserModel user) {
//        return wxLoginService.login(user);
//    }




    /**
     * @Description 获取手机号
     * @Author HH
     * @Date 2023/4/12 13:55
     * @Return com.zhuiYun.project.common.response.AjaxResult
     */
    @GetMapping("/getPhoneNum")
    public AjaxResult getPhoneNum(String code) {

        return success(wxLoginService.getPhoneNum(code));
    }
}

